package service.impl;

import dao.MedDevClassMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.MedDevClass;
import service.MedDevClassService;

import java.util.List;

@Service
public class MedDevClassServiceImpl implements MedDevClassService {
    @Autowired
    private MedDevClassMapper medDevClassMapper;

    @Override
    public List<MedDevClass> findAllMedDevClass(){
        return medDevClassMapper.findAllMedDevClass();
    }

    @Override
    public List<MedDevClass> findMedDevClassByParams(MedDevClass medDevClass){
        return medDevClassMapper.findMedDevClassByNameAndDes(medDevClass);
    }
    @Override
    public MedDevClass findMedDevClassById(int id){
        return medDevClassMapper.selectMedDevClassById(id);
    }

    @Override
    public MedDevClass saveMedDevClass(MedDevClass medDevClass){
        if (medDevClass.getId()==null)
            medDevClassMapper.insertMedDevClass(medDevClass);
        else
            medDevClassMapper.updateMedDevClassById(medDevClass);
        return medDevClass;
    }
    @Override
    public void delMedDevClassById(Integer id){
        medDevClassMapper.delMedDevClassById(id);
    }
}